import { defineStore } from 'pinia'
import { getListCutApi,PostListCutApi,deleteCutApi,postUpdateCutApi } from '@/api/table-cut'
// import { logDark } from 'naive-ui'

export const TablecutStore = defineStore('tablecutStore', {
	state: () => {
		return {
			list: [{}],
			cutList:[],
		}
	},
	getters: {
		
	},
	actions:{
		async SavecutList(form:any){
			if(form._id){
				await postUpdateCutApi(form)
			}else{
			  await PostListCutApi(form)
			}
		},
		async	getcutList(){
			const { data } = await getListCutApi({})
			this.list = data
			const newlist = [];
			this.list.forEach(v => {
				newlist.push({
					value:v.cut,
					label:v.cut
				})
			})
			this.cutList = newlist
		},
		async Deletecut(_id:string) {
		    await deleteCutApi({ _id })
		}
	},
})